
public class e045 {
    public static void main(String[] args) {
        long sTime = System.currentTimeMillis();
        double n = 257;
        while (!isPentagonal(n * (2 * n - 1))){
            n++;
        }
        System.out.println((long)(n * (2 * n - 1)));
        long fTime = System.currentTimeMillis();
        System.out.println("Time: " + (fTime - sTime) + "ms");
    }

    static boolean isPentagonal(double i) {
        return (((Math.sqrt(24 * i + 1) + 1) / 6) % 1 == 0);
    }
}